"""
box.py --                                                                                            
                                                                                                                                                                                                        
It sets a box box's geometric properties.                                              
                                                                                                                                                                                                            
Date of creation: 2007-04-20                                                                        
                                                                                                                                                                                                
Copyright  Robotics and Automation Group, Pontificia Universidad Javeriana - Cali.                  
    Freddy Naranjo Perez, fnaranjo@puj.edu.co                                                                   
    Antonio Alejandro Matta Gomez amatta@puj.edu.co                                      
    Julian David Colorado, jdcolorado@puj.edu.co                           
    Juan Camilo Acosta Mejia, jcacosta@puj.edu.co                                    
                                                                                                                                                                                                        
See the file "license.terms" for information on usage and redistribution of this file, and for a    
DISCLAIMER OF ALL WARRANTIES.
"""

import vtk

class Box:
  def __init__( self, ren, geomdim, posorient, lighting, color ):
        """ Inits a box's figure and its associated material propeties"""
        
        #setting the box geometric parameters.
        self.box = vtk.vtkCubeSource()
        self.box.SetXLength( geomdim[0] -0.02 )
        self.box.SetYLength( geomdim[1] - 0.02 )
        self.box.SetZLength( geomdim[2] -0.02  ) 
        self.boxMapper = vtk.vtkPolyDataMapper()
        self.boxMapper.SetInputConnection(self.box.GetOutputPort())
        self.boxActor = vtk.vtkActor()
        self.boxActor.SetMapper(self.boxMapper)
        self.boxActor.AddPosition( 0.0, geomdim[1] - 0.04, 0.0 )
        #Type of representation.
        self.boxActor.GetProperty().SetRepresentationToSurface ()
        self.boxActor.GetProperty().SetInterpolationToFlat( )
         #Lighting Properties.
        self.boxActor.GetProperty().SetOpacity( lighting[0] )
        self.boxActor.GetProperty().SetAmbient( lighting[1] )
        self.boxActor.GetProperty().SetDiffuse(  lighting[2] )
        self.boxActor.GetProperty().SetSpecular(  lighting[3] )
        self.boxActor.GetProperty().SetSpecularPower(  lighting[4] )     
        # Color Properties.
        self.boxActor.GetProperty().SetAmbientColor( color[0] )
        self.boxActor.GetProperty().SetDiffuseColor( color[1] )
        self.boxActor.GetProperty().SetSpecularColor( color[2] )
        
        #setting the box geometric parameters.
        self.box1 = vtk.vtkCubeSource()
        self.box1.SetXLength( geomdim[0] + 0.05 )
        self.box1.SetYLength( geomdim[1] - 0.04 )
        self.box1.SetZLength( geomdim[2] +0.05 ) 
        self.box1Mapper = vtk.vtkPolyDataMapper()
        self.box1Mapper.SetInputConnection(self.box1.GetOutputPort())
        self.box1Actor = vtk.vtkActor()
        self.box1Actor.SetMapper(self.box1Mapper)
        #Type of representation.
        self.box1Actor.GetProperty().SetRepresentationToSurface ()
        self.box1Actor.GetProperty().SetInterpolationToFlat( )
         #Lighting Properties.
        self.box1Actor.GetProperty().SetOpacity( lighting[0] )
        self.box1Actor.GetProperty().SetAmbient( lighting[1] )
        self.box1Actor.GetProperty().SetDiffuse(  lighting[2] )
        self.box1Actor.GetProperty().SetSpecular(  lighting[3] )
        self.box1Actor.GetProperty().SetSpecularPower(  lighting[4] )     
        # Color Properties.
        self.box1Actor.GetProperty().SetAmbientColor( color[0] )
        self.box1Actor.GetProperty().SetDiffuseColor( color[1] )
        self.box1Actor.GetProperty().SetSpecularColor( color[2] )
        
        #encapsulate everything into an assembly
        self.boxassembly = vtk.vtkAssembly()
        self.boxassembly.SetPosition( posorient[0], posorient[1], posorient[2] )
        self.boxassembly.SetOrientation( posorient[3], posorient[4], posorient[5] )
        self.boxassembly.AddPart(self.boxActor)
        self.boxassembly.AddPart(self.box1Actor)
        
   
    
        
    
    

        
        
            
        
    

    
  
  